/**
 * @description: 全局变量
 * @param {String} str
 */

// eslint-disable-next-line no-unused-vars
const { protocol } = window.location;
// 环境域名
const envHost = {
  // 对应proxy
  dev: '//vaserviece.10jqka.com.cn',
  //对应测试环境主域名
  test: '//vaserviece.10jqka.com.cn',
  //对应正式环境主域名
  release: '//vaserviece.10jqka.com.cn',
};

type EnvHostKey = keyof typeof envHost;

const CURRENT_MODE = process.env.VUE_APP_CURRENTMODE as EnvHostKey;

const BASE_URL_API = envHost[CURRENT_MODE];

// 相同域名接口申明(自动拼接域名前缀)
const interfaceApi = {
  baseUrl: '/limitUp/index.php',
  // 涨停分析
  limitupAnalysis: '/priceslimithelper/stock/ztstockdatadetail',
  // 热点复盘
  limitupGnlt: '/priceslimithelper/pool/gnlt',
  // 新股池
  newStockPool: '/priceslimithelper/pool/newstock',
  // 炸板池
  onceLimitupPool: '/priceslimithelper/stock/oncelimituppool',
  // 跌停池
  downLimitPool: '/priceslimithelper/stock/downlimitpool',
  // 涨停基因
  ztjy: '/limitUp/index.php',
};
(Object.keys(interfaceApi) as Array<keyof typeof interfaceApi>).forEach(
  key => (interfaceApi[key] = BASE_URL_API + interfaceApi[key])
);

// 不同域名接口申明
const diffHostInterface = {
  //对应开发环境主域名
  dev: {
    // 涨停复盘
    limitupZtfp: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/ztfp',
    // 潜力连板个股
    potentialApi: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/qlg',
    emotion: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/emotion',
    hotspot: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/plate_hot',
    tradeDays: '//dq.10jqka.com.cn/fuyao/trade_data_service/base/v1/get_offset_list_new',
    chartInfo: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/chart_info',
    // 强趋势股
    trendStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/trendstockpool',
    // 历史新高股
    highStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/highstockpool',
    askText: '//apigate.10jqka.com.cn/d/charge/limit_up/operation/ask/text',
    wencaiSwitchApi: '//testm.10jqka.com.cn/d/charge/limit_up/config/switch/info',
    userAuthenticateApi: '//apigate.10jqka.com.cn/d/charge/authcenter/authenticate/charge/v2/verify',
    limitupInfo: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/stock/limit_up/info',
  },
  //对应测试环境主域名
  test: {
    // 涨停复盘
    limitupZtfp: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/ztfp',
    // 潜力连板个股
    potentialApi: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/qlg',
    emotion: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/emotion',
    hotspot: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/plate_hot',
    tradeDays: '//dq.10jqka.com.cn/fuyao/trade_data_service/base/v1/get_offset_list_new',
    chartInfo: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/chart_info',
    // 强趋势股
    trendStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/trendstockpool',
    // 历史新高股
    highStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/highstockpool',
    askText: '//apigate.10jqka.com.cn/d/charge/limit_up/operation/ask/text',
    wencaiSwitchApi: '//apigate.10jqka.com.cn/d/charge/limit_up/config/switch/info',
    userAuthenticateApi: '//apigate.10jqka.com.cn/d/charge/authcenter/authenticate/charge/v2/verify',
    limitupInfo: '//testm.10jqka.com.cn/d/charge/limit_up/market/query/v1/stock/limit_up/info',
  },
  //对应正式环境主域名
  release: {
    // 涨停复盘
    limitupZtfp: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/ztfp',
    // 潜力连板个股
    potentialApi: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/pool/qlg',
    emotion: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/emotion',
    hotspot: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/plate_hot',
    tradeDays: '//dq.10jqka.com.cn/fuyao/trade_data_service/base/v1/get_offset_list_new',
    chartInfo: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/chart_info',
    // 强趋势股
    trendStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/trendstockpool',
    // 历史新高股
    highStockPool: '//l2.10jqka.com.cn/priceslimithelper/stock/highstockpool',
    askText: '//apigate.10jqka.com.cn/d/charge/limit_up/operation/ask/text',
    wencaiSwitchApi: '//apigate.10jqka.com.cn/d/charge/limit_up/config/switch/info',
    userAuthenticateApi: '//apigate.10jqka.com.cn/d/charge/authcenter/authenticate/charge/v2/verify',
    limitupInfo: '//apigate.10jqka.com.cn/d/charge/limit_up/market/query/v1/stock/limit_up/info',
  },
};

export default {
  stat: {
    // 原先老的埋点
    oldPageId: 'pdt_pms_269',
    pageId: 'ths_shoufeipd_smallchargeztzs',
    // eslint-disable-next-line camelcase
    url_ver: 'YRJ-5207',
  },

  api: {
    ...interfaceApi,
    // 其余域名自行填充
    ...diffHostInterface[CURRENT_MODE],
  },

  url: {
    oldPage:`${location.protocol}//vaserviece.10jqka.com.cn/limitUp/index.html#/`,
    // 续费页面
    renewalLink:
      '//ozone.10jqka.com.cn/tg_templates/doubleone/2020-q1/limitupRenewal/renewal.html?enter_sign=strategyNormal&scene_sign=juece_xufei',
    // 购买页
    buyPage: '//ozone.10jqka.com.cn/tg_templates/vaserviece/limitUp/index.html',
    buyPageNew: '//ozone.10jqka.com.cn/tg_templates/vaserviece/limitUp/indexfl.html',
    // 功能介绍页面
    productDescLink: '//vaserviece.10jqka.com.cn/limitUp/des.html',
  },
};
